<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - Lua 5.4.0-alpha - src/lbaselib.c</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - lbaselib.c</td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">Lua 5.4.0-alpha</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">268</td>
            <td class="headerCovTableEntry">270</td>
            <td class="headerCovTableEntryHi">99.3 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2019-06-13 19:44:19</td>
            <td></td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<span class="lineNum">       1 </span>            : /*
<span class="lineNum">       2 </span>            : ** $Id: lbaselib.c $
<span class="lineNum">       3 </span>            : ** Basic library
<span class="lineNum">       4 </span>            : ** See Copyright Notice in lua.h
<span class="lineNum">       5 </span>            : */
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : #define lbaselib_c
<span class="lineNum">       8 </span>            : #define LUA_LIB
<span class="lineNum">       9 </span>            : 
<span class="lineNum">      10 </span>            : #include &quot;lprefix.h&quot;
<span class="lineNum">      11 </span>            : 
<span class="lineNum">      12 </span>            : 
<span class="lineNum">      13 </span>            : #include &lt;ctype.h&gt;
<span class="lineNum">      14 </span>            : #include &lt;stdio.h&gt;
<span class="lineNum">      15 </span>            : #include &lt;stdlib.h&gt;
<span class="lineNum">      16 </span>            : #include &lt;string.h&gt;
<span class="lineNum">      17 </span>            : 
<span class="lineNum">      18 </span>            : #include &quot;lua.h&quot;
<span class="lineNum">      19 </span>            : 
<span class="lineNum">      20 </span>            : #include &quot;lauxlib.h&quot;
<span class="lineNum">      21 </span>            : #include &quot;lualib.h&quot;
<span class="lineNum">      22 </span>            : 
<span class="lineNum">      23 </span>            : 
<span class="lineNum">      24 </span><span class="lineCov">       2111 : static int luaB_print (lua_State *L) {</span>
<span class="lineNum">      25 </span><span class="lineCov">       2111 :   int n = lua_gettop(L);  /* number of arguments */</span>
<span class="lineNum">      26 </span>            :   int i;
<span class="lineNum">      27 </span><span class="lineCov">       4225 :   for (i = 1; i &lt;= n; i++) {  /* for each argument */</span>
<span class="lineNum">      28 </span>            :     size_t l;
<span class="lineNum">      29 </span><span class="lineCov">       2115 :     const char *s = luaL_tolstring(L, i, &amp;l);  /* convert it to string */</span>
<span class="lineNum">      30 </span><span class="lineCov">       2114 :     if (i &gt; 1)  /* not the first element? */</span>
<span class="lineNum">      31 </span><span class="lineCov">          4 :       lua_writestring(&quot;\t&quot;, 1);  /* add a tab before it */</span>
<span class="lineNum">      32 </span><span class="lineCov">       2114 :     lua_writestring(s, l);  /* print it */</span>
<span class="lineNum">      33 </span><span class="lineCov">       2114 :     lua_pop(L, 1);  /* pop result */</span>
<span class="lineNum">      34 </span>            :   }
<span class="lineNum">      35 </span><span class="lineCov">       2110 :   lua_writeline();</span>
<span class="lineNum">      36 </span><span class="lineCov">       2110 :   return 0;</span>
<span class="lineNum">      37 </span>            : }
<span class="lineNum">      38 </span>            : 
<span class="lineNum">      39 </span>            : 
<span class="lineNum">      40 </span>            : /*
<span class="lineNum">      41 </span>            : ** Creates a warning with all given arguments.
<span class="lineNum">      42 </span>            : ** Check first for errors; otherwise an error may interrupt
<span class="lineNum">      43 </span>            : ** the composition of a warning, leaving it unfinished.
<span class="lineNum">      44 </span>            : */
<span class="lineNum">      45 </span><span class="lineCov">          5 : static int luaB_warn (lua_State *L) {</span>
<span class="lineNum">      46 </span><span class="lineCov">          5 :   int n = lua_gettop(L);  /* number of arguments */</span>
<span class="lineNum">      47 </span>            :   int i;
<span class="lineNum">      48 </span><span class="lineCov">          5 :   luaL_checkstring(L, 1);  /* at least one argument */</span>
<span class="lineNum">      49 </span><span class="lineCov">          5 :   for (i = 2; i &lt;= n; i++)</span>
<span class="lineNum">      50 </span><span class="lineCov">          2 :     luaL_checkstring(L, i);  /* make sure all arguments are strings */</span>
<span class="lineNum">      51 </span><span class="lineCov">          7 :   for (i = 1; i &lt;= n; i++)  /* compose warning */</span>
<span class="lineNum">      52 </span><span class="lineCov">          4 :     lua_warning(L, lua_tostring(L, i), 1);</span>
<span class="lineNum">      53 </span><span class="lineCov">          3 :   lua_warning(L, &quot;&quot;, 0);  /* close warning */</span>
<span class="lineNum">      54 </span><span class="lineCov">          3 :   return 0;</span>
<span class="lineNum">      55 </span>            : }
<span class="lineNum">      56 </span>            : 
<span class="lineNum">      57 </span>            : 
<span class="lineNum">      58 </span>            : #define SPACECHARS      &quot; \f\n\r\t\v&quot;
<span class="lineNum">      59 </span>            : 
<span class="lineNum">      60 </span><span class="lineCov">          3 : static const char *b_str2int (const char *s, int base, lua_Integer *pn) {</span>
<span class="lineNum">      61 </span><span class="lineCov">          3 :   lua_Unsigned n = 0;</span>
<span class="lineNum">      62 </span><span class="lineCov">          3 :   int neg = 0;</span>
<span class="lineNum">      63 </span><span class="lineCov">          3 :   s += strspn(s, SPACECHARS);  /* skip initial spaces */</span>
<span class="lineNum">      64 </span><span class="lineCov">          3 :   if (*s == '-') { s++; neg = 1; }  /* handle sign */</span>
<span class="lineNum">      65 </span><span class="lineCov">          3 :   else if (*s == '+') s++;</span>
<span class="lineNum">      66 </span><span class="lineCov">          3 :   if (!isalnum((unsigned char)*s))  /* no digit? */</span>
<span class="lineNum">      67 </span><span class="lineNoCov">          0 :     return NULL;</span>
<span class="lineNum">      68 </span>            :   do {
<span class="lineNum">      69 </span><span class="lineCov">         27 :     int digit = (isdigit((unsigned char)*s)) ? *s - '0'</span>
<span class="lineNum">      70 </span><span class="lineCov">          9 :                    : (toupper((unsigned char)*s) - 'A') + 10;</span>
<span class="lineNum">      71 </span><span class="lineCov">          9 :     if (digit &gt;= base) return NULL;  /* invalid numeral */</span>
<span class="lineNum">      72 </span><span class="lineCov">          9 :     n = n * base + digit;</span>
<span class="lineNum">      73 </span><span class="lineCov">          9 :     s++;</span>
<span class="lineNum">      74 </span><span class="lineCov">          9 :   } while (isalnum((unsigned char)*s));</span>
<span class="lineNum">      75 </span><span class="lineCov">          3 :   s += strspn(s, SPACECHARS);  /* skip trailing spaces */</span>
<span class="lineNum">      76 </span><span class="lineCov">          3 :   *pn = (lua_Integer)((neg) ? (0u - n) : n);</span>
<span class="lineNum">      77 </span><span class="lineCov">          3 :   return s;</span>
<span class="lineNum">      78 </span>            : }
<span class="lineNum">      79 </span>            : 
<span class="lineNum">      80 </span>            : 
<span class="lineNum">      81 </span><span class="lineCov">        123 : static int luaB_tonumber (lua_State *L) {</span>
<span class="lineNum">      82 </span><span class="lineCov">        123 :   if (lua_isnoneornil(L, 2)) {  /* standard conversion? */</span>
<span class="lineNum">      83 </span><span class="lineCov">        119 :     if (lua_type(L, 1) == LUA_TNUMBER) {  /* already a number? */</span>
<span class="lineNum">      84 </span><span class="lineCov">        103 :       lua_settop(L, 1);  /* yes; return it */</span>
<span class="lineNum">      85 </span><span class="lineCov">        103 :       return 1;</span>
<span class="lineNum">      86 </span>            :     }
<span class="lineNum">      87 </span>            :     else {
<span class="lineNum">      88 </span>            :       size_t l;
<span class="lineNum">      89 </span><span class="lineCov">         16 :       const char *s = lua_tolstring(L, 1, &amp;l);</span>
<span class="lineNum">      90 </span><span class="lineCov">         16 :       if (s != NULL &amp;&amp; lua_stringtonumber(L, s) == l + 1)</span>
<span class="lineNum">      91 </span><span class="lineCov">         12 :         return 1;  /* successful conversion to number */</span>
<span class="lineNum">      92 </span>            :       /* else not a number */
<span class="lineNum">      93 </span><span class="lineCov">          4 :       luaL_checkany(L, 1);  /* (but there must be some parameter) */</span>
<span class="lineNum">      94 </span>            :     }
<span class="lineNum">      95 </span>            :   }
<span class="lineNum">      96 </span>            :   else {
<span class="lineNum">      97 </span>            :     size_t l;
<span class="lineNum">      98 </span>            :     const char *s;
<span class="lineNum">      99 </span><span class="lineCov">          4 :     lua_Integer n = 0;  /* to avoid warnings */</span>
<span class="lineNum">     100 </span><span class="lineCov">          4 :     lua_Integer base = luaL_checkinteger(L, 2);</span>
<span class="lineNum">     101 </span><span class="lineCov">          4 :     luaL_checktype(L, 1, LUA_TSTRING);  /* no numbers as strings */</span>
<span class="lineNum">     102 </span><span class="lineCov">          4 :     s = lua_tolstring(L, 1, &amp;l);</span>
<span class="lineNum">     103 </span><span class="lineCov">          4 :     luaL_argcheck(L, 2 &lt;= base &amp;&amp; base &lt;= 36, 2, &quot;base out of range&quot;);</span>
<span class="lineNum">     104 </span><span class="lineCov">          3 :     if (b_str2int(s, (int)base, &amp;n) == s + l) {</span>
<span class="lineNum">     105 </span><span class="lineCov">          3 :       lua_pushinteger(L, n);</span>
<span class="lineNum">     106 </span><span class="lineCov">          3 :       return 1;</span>
<span class="lineNum">     107 </span>            :     }  /* else not a number */
<span class="lineNum">     108 </span>            :   }  /* else not a number */
<span class="lineNum">     109 </span><span class="lineCov">          3 :   lua_pushnil(L);  /* not a number */</span>
<span class="lineNum">     110 </span><span class="lineCov">          3 :   return 1;</span>
<span class="lineNum">     111 </span>            : }
<span class="lineNum">     112 </span>            : 
<span class="lineNum">     113 </span>            : 
<span class="lineNum">     114 </span><span class="lineCov">         22 : static int luaB_error (lua_State *L) {</span>
<span class="lineNum">     115 </span><span class="lineCov">         22 :   int level = (int)luaL_optinteger(L, 2, 1);</span>
<span class="lineNum">     116 </span><span class="lineCov">         22 :   lua_settop(L, 1);</span>
<span class="lineNum">     117 </span><span class="lineCov">         22 :   if (lua_type(L, 1) == LUA_TSTRING &amp;&amp; level &gt; 0) {</span>
<span class="lineNum">     118 </span><span class="lineCov">         14 :     luaL_where(L, level);   /* add extra information */</span>
<span class="lineNum">     119 </span><span class="lineCov">         14 :     lua_pushvalue(L, 1);</span>
<span class="lineNum">     120 </span><span class="lineCov">         14 :     lua_concat(L, 2);</span>
<span class="lineNum">     121 </span>            :   }
<span class="lineNum">     122 </span><span class="lineCov">         22 :   return lua_error(L);</span>
<span class="lineNum">     123 </span>            : }
<span class="lineNum">     124 </span>            : 
<span class="lineNum">     125 </span>            : 
<span class="lineNum">     126 </span><span class="lineCov">         13 : static int luaB_getmetatable (lua_State *L) {</span>
<span class="lineNum">     127 </span><span class="lineCov">         13 :   luaL_checkany(L, 1);</span>
<span class="lineNum">     128 </span><span class="lineCov">         13 :   if (!lua_getmetatable(L, 1)) {</span>
<span class="lineNum">     129 </span><span class="lineCov">          5 :     lua_pushnil(L);</span>
<span class="lineNum">     130 </span><span class="lineCov">          5 :     return 1;  /* no metatable */</span>
<span class="lineNum">     131 </span>            :   }
<span class="lineNum">     132 </span><span class="lineCov">          8 :   luaL_getmetafield(L, 1, &quot;__metatable&quot;);</span>
<span class="lineNum">     133 </span><span class="lineCov">          8 :   return 1;  /* returns either __metatable field (if present) or metatable */</span>
<span class="lineNum">     134 </span>            : }
<span class="lineNum">     135 </span>            : 
<span class="lineNum">     136 </span>            : 
<span class="lineNum">     137 </span><span class="lineCov">         96 : static int luaB_setmetatable (lua_State *L) {</span>
<span class="lineNum">     138 </span><span class="lineCov">         96 :   int t = lua_type(L, 2);</span>
<span class="lineNum">     139 </span><span class="lineCov">         96 :   luaL_checktype(L, 1, LUA_TTABLE);</span>
<span class="lineNum">     140 </span><span class="lineCov">         96 :   luaL_argexpected(L, t == LUA_TNIL || t == LUA_TTABLE, 2, &quot;nil or table&quot;);</span>
<span class="lineNum">     141 </span><span class="lineCov">         95 :   if (luaL_getmetafield(L, 1, &quot;__metatable&quot;) != LUA_TNIL)</span>
<span class="lineNum">     142 </span><span class="lineCov">          1 :     return luaL_error(L, &quot;cannot change a protected metatable&quot;);</span>
<span class="lineNum">     143 </span><span class="lineCov">         94 :   lua_settop(L, 2);</span>
<span class="lineNum">     144 </span><span class="lineCov">         94 :   lua_setmetatable(L, 1);</span>
<span class="lineNum">     145 </span><span class="lineCov">         94 :   return 1;</span>
<span class="lineNum">     146 </span>            : }
<span class="lineNum">     147 </span>            : 
<span class="lineNum">     148 </span>            : 
<span class="lineNum">     149 </span><span class="lineCov">         17 : static int luaB_rawequal (lua_State *L) {</span>
<span class="lineNum">     150 </span><span class="lineCov">         17 :   luaL_checkany(L, 1);</span>
<span class="lineNum">     151 </span><span class="lineCov">         17 :   luaL_checkany(L, 2);</span>
<span class="lineNum">     152 </span><span class="lineCov">         17 :   lua_pushboolean(L, lua_rawequal(L, 1, 2));</span>
<span class="lineNum">     153 </span><span class="lineCov">         17 :   return 1;</span>
<span class="lineNum">     154 </span>            : }
<span class="lineNum">     155 </span>            : 
<span class="lineNum">     156 </span>            : 
<span class="lineNum">     157 </span><span class="lineCov">          3 : static int luaB_rawlen (lua_State *L) {</span>
<span class="lineNum">     158 </span><span class="lineCov">          3 :   int t = lua_type(L, 1);</span>
<span class="lineNum">     159 </span><span class="lineCov">          3 :   luaL_argexpected(L, t == LUA_TTABLE || t == LUA_TSTRING, 1,</span>
<span class="lineNum">     160 </span>            :                       &quot;table or string&quot;);
<span class="lineNum">     161 </span><span class="lineCov">          2 :   lua_pushinteger(L, lua_rawlen(L, 1));</span>
<span class="lineNum">     162 </span><span class="lineCov">          2 :   return 1;</span>
<span class="lineNum">     163 </span>            : }
<span class="lineNum">     164 </span>            : 
<span class="lineNum">     165 </span>            : 
<span class="lineNum">     166 </span><span class="lineCov">          5 : static int luaB_rawget (lua_State *L) {</span>
<span class="lineNum">     167 </span><span class="lineCov">          5 :   luaL_checktype(L, 1, LUA_TTABLE);</span>
<span class="lineNum">     168 </span><span class="lineCov">          5 :   luaL_checkany(L, 2);</span>
<span class="lineNum">     169 </span><span class="lineCov">          5 :   lua_settop(L, 2);</span>
<span class="lineNum">     170 </span><span class="lineCov">          5 :   lua_rawget(L, 1);</span>
<span class="lineNum">     171 </span><span class="lineCov">          5 :   return 1;</span>
<span class="lineNum">     172 </span>            : }
<span class="lineNum">     173 </span>            : 
<span class="lineNum">     174 </span><span class="lineCov">          3 : static int luaB_rawset (lua_State *L) {</span>
<span class="lineNum">     175 </span><span class="lineCov">          3 :   luaL_checktype(L, 1, LUA_TTABLE);</span>
<span class="lineNum">     176 </span><span class="lineCov">          3 :   luaL_checkany(L, 2);</span>
<span class="lineNum">     177 </span><span class="lineCov">          3 :   luaL_checkany(L, 3);</span>
<span class="lineNum">     178 </span><span class="lineCov">          3 :   lua_settop(L, 3);</span>
<span class="lineNum">     179 </span><span class="lineCov">          3 :   lua_rawset(L, 1);</span>
<span class="lineNum">     180 </span><span class="lineCov">          2 :   return 1;</span>
<span class="lineNum">     181 </span>            : }
<span class="lineNum">     182 </span>            : 
<span class="lineNum">     183 </span>            : 
<span class="lineNum">     184 </span><span class="lineCov">          4 : static int pushmode (lua_State *L, int oldmode) {</span>
<span class="lineNum">     185 </span><span class="lineCov">          4 :   lua_pushstring(L, (oldmode == LUA_GCINC) ? &quot;incremental&quot; : &quot;generational&quot;);</span>
<span class="lineNum">     186 </span><span class="lineCov">          4 :   return 1;</span>
<span class="lineNum">     187 </span>            : }
<span class="lineNum">     188 </span>            : 
<span class="lineNum">     189 </span>            : 
<span class="lineNum">     190 </span><span class="lineCov">         17 : static int luaB_collectgarbage (lua_State *L) {</span>
<span class="lineNum">     191 </span>            :   static const char *const opts[] = {&quot;stop&quot;, &quot;restart&quot;, &quot;collect&quot;,
<span class="lineNum">     192 </span>            :     &quot;count&quot;, &quot;step&quot;, &quot;setpause&quot;, &quot;setstepmul&quot;,
<span class="lineNum">     193 </span>            :     &quot;isrunning&quot;, &quot;generational&quot;, &quot;incremental&quot;, NULL};
<span class="lineNum">     194 </span>            :   static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
<span class="lineNum">     195 </span>            :     LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL,
<span class="lineNum">     196 </span>            :     LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC};
<span class="lineNum">     197 </span><span class="lineCov">         17 :   int o = optsnum[luaL_checkoption(L, 1, &quot;collect&quot;, opts)];</span>
<span class="lineNum">     198 </span><span class="lineCov">         16 :   switch (o) {</span>
<span class="lineNum">     199 </span><span class="lineCov">          1 :     case LUA_GCCOUNT: {</span>
<span class="lineNum">     200 </span><span class="lineCov">          1 :       int k = lua_gc(L, o);</span>
<span class="lineNum">     201 </span><span class="lineCov">          1 :       int b = lua_gc(L, LUA_GCCOUNTB);</span>
<span class="lineNum">     202 </span><span class="lineCov">          1 :       lua_pushnumber(L, (lua_Number)k + ((lua_Number)b/1024));</span>
<span class="lineNum">     203 </span><span class="lineCov">          1 :       return 1;</span>
<span class="lineNum">     204 </span>            :     }
<span class="lineNum">     205 </span><span class="lineCov">          3 :     case LUA_GCSTEP: {</span>
<span class="lineNum">     206 </span><span class="lineCov">          3 :       int step = (int)luaL_optinteger(L, 2, 0);</span>
<span class="lineNum">     207 </span><span class="lineCov">          3 :       int res = lua_gc(L, o, step);</span>
<span class="lineNum">     208 </span><span class="lineCov">          3 :       lua_pushboolean(L, res);</span>
<span class="lineNum">     209 </span><span class="lineCov">          3 :       return 1;</span>
<span class="lineNum">     210 </span>            :     }
<span class="lineNum">     211 </span><span class="lineCov">          2 :     case LUA_GCSETPAUSE:</span>
<span class="lineNum">     212 </span>            :     case LUA_GCSETSTEPMUL: {
<span class="lineNum">     213 </span><span class="lineCov">          2 :       int p = (int)luaL_optinteger(L, 2, 0);</span>
<span class="lineNum">     214 </span><span class="lineCov">          2 :       int previous = lua_gc(L, o, p);</span>
<span class="lineNum">     215 </span><span class="lineCov">          2 :       lua_pushinteger(L, previous);</span>
<span class="lineNum">     216 </span><span class="lineCov">          2 :       return 1;</span>
<span class="lineNum">     217 </span>            :     }
<span class="lineNum">     218 </span><span class="lineCov">          2 :     case LUA_GCISRUNNING: {</span>
<span class="lineNum">     219 </span><span class="lineCov">          2 :       int res = lua_gc(L, o);</span>
<span class="lineNum">     220 </span><span class="lineCov">          2 :       lua_pushboolean(L, res);</span>
<span class="lineNum">     221 </span><span class="lineCov">          2 :       return 1;</span>
<span class="lineNum">     222 </span>            :     }
<span class="lineNum">     223 </span><span class="lineCov">          2 :     case LUA_GCGEN: {</span>
<span class="lineNum">     224 </span><span class="lineCov">          2 :       int minormul = (int)luaL_optinteger(L, 2, 0);</span>
<span class="lineNum">     225 </span><span class="lineCov">          2 :       int majormul = (int)luaL_optinteger(L, 3, 0);</span>
<span class="lineNum">     226 </span><span class="lineCov">          2 :       return pushmode(L, lua_gc(L, o, minormul, majormul));</span>
<span class="lineNum">     227 </span>            :     }
<span class="lineNum">     228 </span><span class="lineCov">          2 :     case LUA_GCINC: {</span>
<span class="lineNum">     229 </span><span class="lineCov">          2 :       int pause = (int)luaL_optinteger(L, 2, 0);</span>
<span class="lineNum">     230 </span><span class="lineCov">          2 :       int stepmul = (int)luaL_optinteger(L, 3, 0);</span>
<span class="lineNum">     231 </span><span class="lineCov">          2 :       int stepsize = (int)luaL_optinteger(L, 4, 0);</span>
<span class="lineNum">     232 </span><span class="lineCov">          2 :       return pushmode(L, lua_gc(L, o, pause, stepmul, stepsize));</span>
<span class="lineNum">     233 </span>            :     }
<span class="lineNum">     234 </span><span class="lineCov">          4 :     default: {</span>
<span class="lineNum">     235 </span><span class="lineCov">          4 :       int res = lua_gc(L, o);</span>
<span class="lineNum">     236 </span><span class="lineCov">          4 :       lua_pushinteger(L, res);</span>
<span class="lineNum">     237 </span><span class="lineCov">          4 :       return 1;</span>
<span class="lineNum">     238 </span>            :     }
<span class="lineNum">     239 </span>            :   }
<span class="lineNum">     240 </span>            : }
<span class="lineNum">     241 </span>            : 
<span class="lineNum">     242 </span>            : 
<span class="lineNum">     243 </span><span class="lineCov">        130 : static int luaB_type (lua_State *L) {</span>
<span class="lineNum">     244 </span><span class="lineCov">        130 :   int t = lua_type(L, 1);</span>
<span class="lineNum">     245 </span><span class="lineCov">        130 :   luaL_argcheck(L, t != LUA_TNONE, 1, &quot;value expected&quot;);</span>
<span class="lineNum">     246 </span><span class="lineCov">        129 :   lua_pushstring(L, lua_typename(L, t));</span>
<span class="lineNum">     247 </span><span class="lineCov">        129 :   return 1;</span>
<span class="lineNum">     248 </span>            : }
<span class="lineNum">     249 </span>            : 
<span class="lineNum">     250 </span>            : 
<span class="lineNum">     251 </span><span class="lineCov">         45 : static int luaB_next (lua_State *L) {</span>
<span class="lineNum">     252 </span><span class="lineCov">         45 :   luaL_checktype(L, 1, LUA_TTABLE);</span>
<span class="lineNum">     253 </span><span class="lineCov">         44 :   lua_settop(L, 2);  /* create a 2nd argument if there isn't one */</span>
<span class="lineNum">     254 </span><span class="lineCov">         44 :   if (lua_next(L, 1))</span>
<span class="lineNum">     255 </span><span class="lineCov">         31 :     return 2;</span>
<span class="lineNum">     256 </span>            :   else {
<span class="lineNum">     257 </span><span class="lineCov">         12 :     lua_pushnil(L);</span>
<span class="lineNum">     258 </span><span class="lineCov">         12 :     return 1;</span>
<span class="lineNum">     259 </span>            :   }
<span class="lineNum">     260 </span>            : }
<span class="lineNum">     261 </span>            : 
<span class="lineNum">     262 </span>            : 
<span class="lineNum">     263 </span><span class="lineCov">          7 : static int luaB_pairs (lua_State *L) {</span>
<span class="lineNum">     264 </span><span class="lineCov">          7 :   luaL_checkany(L, 1);</span>
<span class="lineNum">     265 </span><span class="lineCov">          7 :   if (luaL_getmetafield(L, 1, &quot;__pairs&quot;) == LUA_TNIL) {  /* no metamethod? */</span>
<span class="lineNum">     266 </span><span class="lineCov">          6 :     lua_pushcfunction(L, luaB_next);  /* will return generator, */</span>
<span class="lineNum">     267 </span><span class="lineCov">          6 :     lua_pushvalue(L, 1);  /* state, */</span>
<span class="lineNum">     268 </span><span class="lineCov">          6 :     lua_pushnil(L);  /* and initial value */</span>
<span class="lineNum">     269 </span>            :   }
<span class="lineNum">     270 </span>            :   else {
<span class="lineNum">     271 </span><span class="lineCov">          1 :     lua_pushvalue(L, 1);  /* argument 'self' to metamethod */</span>
<span class="lineNum">     272 </span><span class="lineCov">          1 :     lua_call(L, 1, 3);  /* get 3 values from metamethod */</span>
<span class="lineNum">     273 </span>            :   }
<span class="lineNum">     274 </span><span class="lineCov">          7 :   return 3;</span>
<span class="lineNum">     275 </span>            : }
<span class="lineNum">     276 </span>            : 
<span class="lineNum">     277 </span>            : 
<span class="lineNum">     278 </span>            : /*
<span class="lineNum">     279 </span>            : ** Traversal function for 'ipairs'
<span class="lineNum">     280 </span>            : */
<span class="lineNum">     281 </span><span class="lineCov">      46283 : static int ipairsaux (lua_State *L) {</span>
<span class="lineNum">     282 </span><span class="lineCov">      46283 :   lua_Integer i = luaL_checkinteger(L, 2) + 1;</span>
<span class="lineNum">     283 </span><span class="lineCov">      46283 :   lua_pushinteger(L, i);</span>
<span class="lineNum">     284 </span><span class="lineCov">      46283 :   return (lua_geti(L, 1, i) == LUA_TNIL) ? 1 : 2;</span>
<span class="lineNum">     285 </span>            : }
<span class="lineNum">     286 </span>            : 
<span class="lineNum">     287 </span>            : 
<span class="lineNum">     288 </span>            : /*
<span class="lineNum">     289 </span>            : ** 'ipairs' function. Returns 'ipairsaux', given &quot;table&quot;, 0.
<span class="lineNum">     290 </span>            : ** (The given &quot;table&quot; may not be a table.)
<span class="lineNum">     291 </span>            : */
<span class="lineNum">     292 </span><span class="lineCov">       5925 : static int luaB_ipairs (lua_State *L) {</span>
<span class="lineNum">     293 </span><span class="lineCov">       5925 :   luaL_checkany(L, 1);</span>
<span class="lineNum">     294 </span><span class="lineCov">       5925 :   lua_pushcfunction(L, ipairsaux);  /* iteration function */</span>
<span class="lineNum">     295 </span><span class="lineCov">       5925 :   lua_pushvalue(L, 1);  /* state */</span>
<span class="lineNum">     296 </span><span class="lineCov">       5925 :   lua_pushinteger(L, 0);  /* initial value */</span>
<span class="lineNum">     297 </span><span class="lineCov">       5925 :   return 3;</span>
<span class="lineNum">     298 </span>            : }
<span class="lineNum">     299 </span>            : 
<span class="lineNum">     300 </span>            : 
<span class="lineNum">     301 </span><span class="lineCov">        223 : static int load_aux (lua_State *L, int status, int envidx) {</span>
<span class="lineNum">     302 </span><span class="lineCov">        223 :   if (status == LUA_OK) {</span>
<span class="lineNum">     303 </span><span class="lineCov">        177 :     if (envidx != 0) {  /* 'env' parameter? */</span>
<span class="lineNum">     304 </span><span class="lineCov">          2 :       lua_pushvalue(L, envidx);  /* environment for loaded function */</span>
<span class="lineNum">     305 </span><span class="lineCov">          2 :       if (!lua_setupvalue(L, -2, 1))  /* set it as 1st upvalue */</span>
<span class="lineNum">     306 </span><span class="lineNoCov">          0 :         lua_pop(L, 1);  /* remove 'env' if not used by previous call */</span>
<span class="lineNum">     307 </span>            :     }
<span class="lineNum">     308 </span><span class="lineCov">        177 :     return 1;</span>
<span class="lineNum">     309 </span>            :   }
<span class="lineNum">     310 </span>            :   else {  /* error (message is on top of the stack) */
<span class="lineNum">     311 </span><span class="lineCov">         46 :     lua_pushnil(L);</span>
<span class="lineNum">     312 </span><span class="lineCov">         46 :     lua_insert(L, -2);  /* put before error message */</span>
<span class="lineNum">     313 </span><span class="lineCov">         46 :     return 2;  /* return nil plus error message */</span>
<span class="lineNum">     314 </span>            :   }
<span class="lineNum">     315 </span>            : }
<span class="lineNum">     316 </span>            : 
<span class="lineNum">     317 </span>            : 
<span class="lineNum">     318 </span><span class="lineCov">          6 : static int luaB_loadfile (lua_State *L) {</span>
<span class="lineNum">     319 </span><span class="lineCov">          6 :   const char *fname = luaL_optstring(L, 1, NULL);</span>
<span class="lineNum">     320 </span><span class="lineCov">          6 :   const char *mode = luaL_optstring(L, 2, NULL);</span>
<span class="lineNum">     321 </span><span class="lineCov">          6 :   int env = (!lua_isnone(L, 3) ? 3 : 0);  /* 'env' index or 0 if no 'env' */</span>
<span class="lineNum">     322 </span><span class="lineCov">          6 :   int status = luaL_loadfilex(L, fname, mode);</span>
<span class="lineNum">     323 </span><span class="lineCov">          6 :   return load_aux(L, status, env);</span>
<span class="lineNum">     324 </span>            : }
<span class="lineNum">     325 </span>            : 
<span class="lineNum">     326 </span>            : 
<span class="lineNum">     327 </span>            : /*
<span class="lineNum">     328 </span>            : ** {======================================================
<span class="lineNum">     329 </span>            : ** Generic Read function
<span class="lineNum">     330 </span>            : ** =======================================================
<span class="lineNum">     331 </span>            : */
<span class="lineNum">     332 </span>            : 
<span class="lineNum">     333 </span>            : 
<span class="lineNum">     334 </span>            : /*
<span class="lineNum">     335 </span>            : ** reserved slot, above all arguments, to hold a copy of the returned
<span class="lineNum">     336 </span>            : ** string to avoid it being collected while parsed. 'load' has four
<span class="lineNum">     337 </span>            : ** optional arguments (chunk, source name, mode, and environment).
<span class="lineNum">     338 </span>            : */
<span class="lineNum">     339 </span>            : #define RESERVEDSLOT    5
<span class="lineNum">     340 </span>            : 
<span class="lineNum">     341 </span>            : 
<span class="lineNum">     342 </span>            : /*
<span class="lineNum">     343 </span>            : ** Reader for generic 'load' function: 'lua_load' uses the
<span class="lineNum">     344 </span>            : ** stack for internal stuff, so the reader cannot change the
<span class="lineNum">     345 </span>            : ** stack top. Instead, it keeps its resulting string in a
<span class="lineNum">     346 </span>            : ** reserved slot inside the stack.
<span class="lineNum">     347 </span>            : */
<span class="lineNum">     348 </span><span class="lineCov">          6 : static const char *generic_reader (lua_State *L, void *ud, size_t *size) {</span>
<span class="lineNum">     349 </span>            :   (void)(ud);  /* not used */
<span class="lineNum">     350 </span><span class="lineCov">          6 :   luaL_checkstack(L, 2, &quot;too many nested functions&quot;);</span>
<span class="lineNum">     351 </span><span class="lineCov">          6 :   lua_pushvalue(L, 1);  /* get function */</span>
<span class="lineNum">     352 </span><span class="lineCov">          6 :   lua_call(L, 0, 1);  /* call it */</span>
<span class="lineNum">     353 </span><span class="lineCov">          6 :   if (lua_isnil(L, -1)) {</span>
<span class="lineNum">     354 </span><span class="lineCov">          3 :     lua_pop(L, 1);  /* pop result */</span>
<span class="lineNum">     355 </span><span class="lineCov">          3 :     *size = 0;</span>
<span class="lineNum">     356 </span><span class="lineCov">          3 :     return NULL;</span>
<span class="lineNum">     357 </span>            :   }
<span class="lineNum">     358 </span><span class="lineCov">          3 :   else if (!lua_isstring(L, -1))</span>
<span class="lineNum">     359 </span><span class="lineCov">          1 :     luaL_error(L, &quot;reader function must return a string&quot;);</span>
<span class="lineNum">     360 </span><span class="lineCov">          2 :   lua_replace(L, RESERVEDSLOT);  /* save string in reserved slot */</span>
<span class="lineNum">     361 </span><span class="lineCov">          2 :   return lua_tolstring(L, RESERVEDSLOT, size);</span>
<span class="lineNum">     362 </span>            : }
<span class="lineNum">     363 </span>            : 
<span class="lineNum">     364 </span>            : 
<span class="lineNum">     365 </span><span class="lineCov">        217 : static int luaB_load (lua_State *L) {</span>
<span class="lineNum">     366 </span>            :   int status;
<span class="lineNum">     367 </span>            :   size_t l;
<span class="lineNum">     368 </span><span class="lineCov">        217 :   const char *s = lua_tolstring(L, 1, &amp;l);</span>
<span class="lineNum">     369 </span><span class="lineCov">        217 :   const char *mode = luaL_optstring(L, 3, &quot;bt&quot;);</span>
<span class="lineNum">     370 </span><span class="lineCov">        217 :   int env = (!lua_isnone(L, 4) ? 4 : 0);  /* 'env' index or 0 if no 'env' */</span>
<span class="lineNum">     371 </span><span class="lineCov">        217 :   if (s != NULL) {  /* loading a string? */</span>
<span class="lineNum">     372 </span><span class="lineCov">        212 :     const char *chunkname = luaL_optstring(L, 2, s);</span>
<span class="lineNum">     373 </span><span class="lineCov">        212 :     status = luaL_loadbufferx(L, s, l, chunkname, mode);</span>
<span class="lineNum">     374 </span>            :   }
<span class="lineNum">     375 </span>            :   else {  /* loading from a reader function */
<span class="lineNum">     376 </span><span class="lineCov">          5 :     const char *chunkname = luaL_optstring(L, 2, &quot;=(load)&quot;);</span>
<span class="lineNum">     377 </span><span class="lineCov">          5 :     luaL_checktype(L, 1, LUA_TFUNCTION);</span>
<span class="lineNum">     378 </span><span class="lineCov">          5 :     lua_settop(L, RESERVEDSLOT);  /* create reserved slot */</span>
<span class="lineNum">     379 </span><span class="lineCov">          5 :     status = lua_load(L, generic_reader, NULL, chunkname, mode);</span>
<span class="lineNum">     380 </span>            :   }
<span class="lineNum">     381 </span><span class="lineCov">        217 :   return load_aux(L, status, env);</span>
<span class="lineNum">     382 </span>            : }
<span class="lineNum">     383 </span>            : 
<span class="lineNum">     384 </span>            : /* }====================================================== */
<span class="lineNum">     385 </span>            : 
<span class="lineNum">     386 </span>            : 
<span class="lineNum">     387 </span><span class="lineCov">         14 : static int dofilecont (lua_State *L, int d1, lua_KContext d2) {</span>
<span class="lineNum">     388 </span>            :   (void)d1;  (void)d2;  /* only to match 'lua_Kfunction' prototype */
<span class="lineNum">     389 </span><span class="lineCov">         14 :   return lua_gettop(L) - 1;</span>
<span class="lineNum">     390 </span>            : }
<span class="lineNum">     391 </span>            : 
<span class="lineNum">     392 </span>            : 
<span class="lineNum">     393 </span><span class="lineCov">         16 : static int luaB_dofile (lua_State *L) {</span>
<span class="lineNum">     394 </span><span class="lineCov">         16 :   const char *fname = luaL_optstring(L, 1, NULL);</span>
<span class="lineNum">     395 </span><span class="lineCov">         16 :   lua_settop(L, 1);</span>
<span class="lineNum">     396 </span><span class="lineCov">         16 :   if (luaL_loadfile(L, fname) != LUA_OK)</span>
<span class="lineNum">     397 </span><span class="lineCov">          2 :     return lua_error(L);</span>
<span class="lineNum">     398 </span><span class="lineCov">         14 :   lua_callk(L, 0, LUA_MULTRET, 0, dofilecont);</span>
<span class="lineNum">     399 </span><span class="lineCov">         14 :   return dofilecont(L, 0, 0);</span>
<span class="lineNum">     400 </span>            : }
<span class="lineNum">     401 </span>            : 
<span class="lineNum">     402 </span>            : 
<span class="lineNum">     403 </span><span class="lineCov">       5929 : static int luaB_assert (lua_State *L) {</span>
<span class="lineNum">     404 </span><span class="lineCov">       5929 :   if (lua_toboolean(L, 1))  /* condition is true? */</span>
<span class="lineNum">     405 </span><span class="lineCov">       5919 :     return lua_gettop(L);  /* return all arguments */</span>
<span class="lineNum">     406 </span>            :   else {  /* error */
<span class="lineNum">     407 </span><span class="lineCov">         10 :     luaL_checkany(L, 1);  /* there must be a condition */</span>
<span class="lineNum">     408 </span><span class="lineCov">          9 :     lua_remove(L, 1);  /* remove it */</span>
<span class="lineNum">     409 </span><span class="lineCov">          9 :     lua_pushliteral(L, &quot;assertion failed!&quot;);  /* default message */</span>
<span class="lineNum">     410 </span><span class="lineCov">          9 :     lua_settop(L, 1);  /* leave only message (default if no other one) */</span>
<span class="lineNum">     411 </span><span class="lineCov">          9 :     return luaB_error(L);  /* call 'error' */</span>
<span class="lineNum">     412 </span>            :   }
<span class="lineNum">     413 </span>            : }
<span class="lineNum">     414 </span>            : 
<span class="lineNum">     415 </span>            : 
<span class="lineNum">     416 </span><span class="lineCov">         12 : static int luaB_select (lua_State *L) {</span>
<span class="lineNum">     417 </span><span class="lineCov">         12 :   int n = lua_gettop(L);</span>
<span class="lineNum">     418 </span><span class="lineCov">         12 :   if (lua_type(L, 1) == LUA_TSTRING &amp;&amp; *lua_tostring(L, 1) == '#') {</span>
<span class="lineNum">     419 </span><span class="lineCov">          2 :     lua_pushinteger(L, n-1);</span>
<span class="lineNum">     420 </span><span class="lineCov">          2 :     return 1;</span>
<span class="lineNum">     421 </span>            :   }
<span class="lineNum">     422 </span>            :   else {
<span class="lineNum">     423 </span><span class="lineCov">         10 :     lua_Integer i = luaL_checkinteger(L, 1);</span>
<span class="lineNum">     424 </span><span class="lineCov">         10 :     if (i &lt; 0) i = n + i;</span>
<span class="lineNum">     425 </span><span class="lineCov">          6 :     else if (i &gt; n) i = n;</span>
<span class="lineNum">     426 </span><span class="lineCov">         10 :     luaL_argcheck(L, 1 &lt;= i, 1, &quot;index out of range&quot;);</span>
<span class="lineNum">     427 </span><span class="lineCov">          8 :     return n - (int)i;</span>
<span class="lineNum">     428 </span>            :   }
<span class="lineNum">     429 </span>            : }
<span class="lineNum">     430 </span>            : 
<span class="lineNum">     431 </span>            : 
<span class="lineNum">     432 </span>            : /*
<span class="lineNum">     433 </span>            : ** Continuation function for 'pcall' and 'xpcall'. Both functions
<span class="lineNum">     434 </span>            : ** already pushed a 'true' before doing the call, so in case of success
<span class="lineNum">     435 </span>            : ** 'finishpcall' only has to return everything in the stack minus
<span class="lineNum">     436 </span>            : ** 'extra' values (where 'extra' is exactly the number of items to be
<span class="lineNum">     437 </span>            : ** ignored).
<span class="lineNum">     438 </span>            : */
<span class="lineNum">     439 </span><span class="lineCov">        644 : static int finishpcall (lua_State *L, int status, lua_KContext extra) {</span>
<span class="lineNum">     440 </span><span class="lineCov">        644 :   if (status != LUA_OK &amp;&amp; status != LUA_YIELD) {  /* error? */</span>
<span class="lineNum">     441 </span><span class="lineCov">        469 :     lua_pushboolean(L, 0);  /* first result (false) */</span>
<span class="lineNum">     442 </span><span class="lineCov">        469 :     lua_pushvalue(L, -2);  /* error message */</span>
<span class="lineNum">     443 </span><span class="lineCov">        469 :     return 2;  /* return false, msg */</span>
<span class="lineNum">     444 </span>            :   }
<span class="lineNum">     445 </span>            :   else
<span class="lineNum">     446 </span><span class="lineCov">        175 :     return lua_gettop(L) - (int)extra;  /* return all results */</span>
<span class="lineNum">     447 </span>            : }
<span class="lineNum">     448 </span>            : 
<span class="lineNum">     449 </span>            : 
<span class="lineNum">     450 </span><span class="lineCov">        637 : static int luaB_pcall (lua_State *L) {</span>
<span class="lineNum">     451 </span>            :   int status;
<span class="lineNum">     452 </span><span class="lineCov">        637 :   luaL_checkany(L, 1);</span>
<span class="lineNum">     453 </span><span class="lineCov">        637 :   lua_pushboolean(L, 1);  /* first result if no errors */</span>
<span class="lineNum">     454 </span><span class="lineCov">        637 :   lua_insert(L, 1);  /* put it in place */</span>
<span class="lineNum">     455 </span><span class="lineCov">        637 :   status = lua_pcallk(L, lua_gettop(L) - 2, LUA_MULTRET, 0, 0, finishpcall);</span>
<span class="lineNum">     456 </span><span class="lineCov">        636 :   return finishpcall(L, status, 0);</span>
<span class="lineNum">     457 </span>            : }
<span class="lineNum">     458 </span>            : 
<span class="lineNum">     459 </span>            : 
<span class="lineNum">     460 </span>            : /*
<span class="lineNum">     461 </span>            : ** Do a protected call with error handling. After 'lua_rotate', the
<span class="lineNum">     462 </span>            : ** stack will have &lt;f, err, true, f, [args...]&gt;; so, the function passes
<span class="lineNum">     463 </span>            : ** 2 to 'finishpcall' to skip the 2 first values when returning results.
<span class="lineNum">     464 </span>            : */
<span class="lineNum">     465 </span><span class="lineCov">          9 : static int luaB_xpcall (lua_State *L) {</span>
<span class="lineNum">     466 </span>            :   int status;
<span class="lineNum">     467 </span><span class="lineCov">          9 :   int n = lua_gettop(L);</span>
<span class="lineNum">     468 </span><span class="lineCov">          9 :   luaL_checktype(L, 2, LUA_TFUNCTION);  /* check error function */</span>
<span class="lineNum">     469 </span><span class="lineCov">          7 :   lua_pushboolean(L, 1);  /* first result */</span>
<span class="lineNum">     470 </span><span class="lineCov">          7 :   lua_pushvalue(L, 1);  /* function */</span>
<span class="lineNum">     471 </span><span class="lineCov">          7 :   lua_rotate(L, 3, 2);  /* move them below function's arguments */</span>
<span class="lineNum">     472 </span><span class="lineCov">          7 :   status = lua_pcallk(L, n - 2, LUA_MULTRET, 2, 2, finishpcall);</span>
<span class="lineNum">     473 </span><span class="lineCov">          6 :   return finishpcall(L, status, 2);</span>
<span class="lineNum">     474 </span>            : }
<span class="lineNum">     475 </span>            : 
<span class="lineNum">     476 </span>            : 
<span class="lineNum">     477 </span><span class="lineCov">       2786 : static int luaB_tostring (lua_State *L) {</span>
<span class="lineNum">     478 </span><span class="lineCov">       2786 :   luaL_checkany(L, 1);</span>
<span class="lineNum">     479 </span><span class="lineCov">       2785 :   luaL_tolstring(L, 1, NULL);</span>
<span class="lineNum">     480 </span><span class="lineCov">       2783 :   return 1;</span>
<span class="lineNum">     481 </span>            : }
<span class="lineNum">     482 </span>            : 
<span class="lineNum">     483 </span>            : 
<span class="lineNum">     484 </span>            : static const luaL_Reg base_funcs[] = {
<span class="lineNum">     485 </span>            :   {&quot;assert&quot;, luaB_assert},
<span class="lineNum">     486 </span>            :   {&quot;collectgarbage&quot;, luaB_collectgarbage},
<span class="lineNum">     487 </span>            :   {&quot;dofile&quot;, luaB_dofile},
<span class="lineNum">     488 </span>            :   {&quot;error&quot;, luaB_error},
<span class="lineNum">     489 </span>            :   {&quot;getmetatable&quot;, luaB_getmetatable},
<span class="lineNum">     490 </span>            :   {&quot;ipairs&quot;, luaB_ipairs},
<span class="lineNum">     491 </span>            :   {&quot;loadfile&quot;, luaB_loadfile},
<span class="lineNum">     492 </span>            :   {&quot;load&quot;, luaB_load},
<span class="lineNum">     493 </span>            :   {&quot;next&quot;, luaB_next},
<span class="lineNum">     494 </span>            :   {&quot;pairs&quot;, luaB_pairs},
<span class="lineNum">     495 </span>            :   {&quot;pcall&quot;, luaB_pcall},
<span class="lineNum">     496 </span>            :   {&quot;print&quot;, luaB_print},
<span class="lineNum">     497 </span>            :   {&quot;warn&quot;, luaB_warn},
<span class="lineNum">     498 </span>            :   {&quot;rawequal&quot;, luaB_rawequal},
<span class="lineNum">     499 </span>            :   {&quot;rawlen&quot;, luaB_rawlen},
<span class="lineNum">     500 </span>            :   {&quot;rawget&quot;, luaB_rawget},
<span class="lineNum">     501 </span>            :   {&quot;rawset&quot;, luaB_rawset},
<span class="lineNum">     502 </span>            :   {&quot;select&quot;, luaB_select},
<span class="lineNum">     503 </span>            :   {&quot;setmetatable&quot;, luaB_setmetatable},
<span class="lineNum">     504 </span>            :   {&quot;tonumber&quot;, luaB_tonumber},
<span class="lineNum">     505 </span>            :   {&quot;tostring&quot;, luaB_tostring},
<span class="lineNum">     506 </span>            :   {&quot;type&quot;, luaB_type},
<span class="lineNum">     507 </span>            :   {&quot;xpcall&quot;, luaB_xpcall},
<span class="lineNum">     508 </span>            :   /* placeholders */
<span class="lineNum">     509 </span>            :   {LUA_GNAME, NULL},
<span class="lineNum">     510 </span>            :   {&quot;_VERSION&quot;, NULL},
<span class="lineNum">     511 </span>            :   {NULL, NULL}
<span class="lineNum">     512 </span>            : };
<span class="lineNum">     513 </span>            : 
<span class="lineNum">     514 </span>            : 
<span class="lineNum">     515 </span><span class="lineCov">         89 : LUAMOD_API int luaopen_base (lua_State *L) {</span>
<span class="lineNum">     516 </span>            :   /* open lib into global table */
<span class="lineNum">     517 </span><span class="lineCov">         89 :   lua_pushglobaltable(L);</span>
<span class="lineNum">     518 </span><span class="lineCov">         89 :   luaL_setfuncs(L, base_funcs, 0);</span>
<span class="lineNum">     519 </span>            :   /* set global _G */
<span class="lineNum">     520 </span><span class="lineCov">         89 :   lua_pushvalue(L, -1);</span>
<span class="lineNum">     521 </span><span class="lineCov">         89 :   lua_setfield(L, -2, LUA_GNAME);</span>
<span class="lineNum">     522 </span>            :   /* set global _VERSION */
<span class="lineNum">     523 </span><span class="lineCov">         89 :   lua_pushliteral(L, LUA_VERSION);</span>
<span class="lineNum">     524 </span><span class="lineCov">         89 :   lua_setfield(L, -2, &quot;_VERSION&quot;);</span>
<span class="lineNum">     525 </span><span class="lineCov">         89 :   return 1;</span>
<span class="lineNum">     526 </span>            : }
<span class="lineNum">     527 </span>            : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.13</a></td></tr>
  </table>
  <br>

</body>
</html>
